//
//  LineGraph.m
//  MUBATE
//
//  Created by sunbin on 2017/2/13.
//  Copyright © 2017年 Quanli. All rights reserved.
//

#import "LineGraph.h"
#import "LineChart.h"


@interface LineGraph()<LineChartDelegate>
@property (nonatomic, strong) LineChart *LCView;

@property (weak, nonatomic) IBOutlet UIView *lineView;
@property (strong, nonatomic) NSMutableArray*data;

@end
@implementation LineGraph

-(NSMutableArray *)data{
    if (!_data) {
        _data = [[NSMutableArray alloc] init];
    }
    return _data;
}

- (void)awakeFromNib {
    [super awakeFromNib];

    LineChart *LCView = [LineChart lineChartViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH , HEIGHT(_lineView))];
    self.LCView = LCView;
    [_lineView addSubview:self.LCView];
    
    // 延迟操作delayMethod bug解决=代理先走 再走drawChartWithLineChartType
    self.LCView.delegate = self;
    [self performSelector:@selector(delayMethod) withObject:nil afterDelay:1.0f];
    
    


}

- (void)lineGraphWithData:(NSMutableArray *)data{
    _data = data;
    [self.LCView reloadData];
}




- (void)delayMethod{
}

#define LineChartDelegate


- (NSArray *)xValues{
    return _data.firstObject;
}

- (NSArray *)yValues{
    return _data.lastObject;
}






- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
